<template>
	<view class="page">
		<u-card :title="title" :thumb="thumb">
			<view slot="body" style="display: flex;flex-direction: column;justify-content: center;width: 100%;align-items: center;">
				<view style="width: 200rpx;height: 200rpx;">
					<u-avatar :src="userDetail.avatarUrl" size="200"></u-avatar>
				</view>
				<view style="margin-top: 30rpx;font-weight: bold;">
					<view style="margin-top: 30rpx;font-weight: bold;">姓名：{{userDetail.nickName}}</view>
					<view style="margin-top: 30rpx;font-weight: bold;">手机号码：{{userDetail.phonenumber}}</view>
					<view style="margin-top: 30rpx;font-weight: bold;">角色：{{userDetail.remark}}</view>
					<view style="margin-top: 30rpx;font-weight: bold;">邮箱：{{userDetail.email}}</view>
					<view style="margin-top: 30rpx;font-weight: bold;">状态：{{userDetail.workLabel}}</view>
				</view>
				
				<view style="margin-top: 30rpx;width: 500rpx;text-align: center;">
					<u-button type="primary" size="medium" @click="show = true">更改当前工作状态</u-button>
				</view>
				
				
				<u-select v-model="show" :list="list" labelName="dictLabel" valueName="dictValue" mode="single-column" @confirm="updateUser"></u-select>
			</view>
		</u-card>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: "个人去向牌",
				subTitle: "个人去向牌",
				thumb: "http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg",
				pic: 'https://uviewui.com/common/logo.png',
				userInfo: {},
				userDetail: {},
				list: [],
				dictLabel: "dictLabel",
				show: false
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync("userInfo")
			this.getInfo()
			this.updateStatus()
		},
		methods: {
			getInfo() {
				this.$request('', '/system/user/getInfoApp', 'GET', {
					userId: this.userInfo.userId
				}, {}).then(res => {
					this.userDetail = res.data
				});
			},
			updateUser(val) {
				console.log(val)
				this.$request('', '/iot/app/updateStatus', 'GET', {
					userId: this.userDetail.userId,
					status: val[0].value
				}, {}).then(res => {
					this.getInfo()
				});
			},
			updateStatus(data) {
				this.$request('', '/system/dict/data/type/app/' + 'sys_status_type', 'GET', {}, {}).then(res => {
					this.list = res.data
				});
			},
		}
	}
</script>

<style>
	page {
		background-color: #FFFFFF;
	}
</style>